<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <base href="<%=basePath%>">

    <title>导出数据信息</title>
    <link href="../css/bootstrap-cerulean.css" rel="stylesheet">
    <link href="../css/charisma-app.css" rel="stylesheet">
    <link href='../css/chosen.css' rel='stylesheet'>
    <link href='../css/uniform.default.css' rel='stylesheet'>
    <link href='../css/uploadify.css' rel='stylesheet'>
    <style type="text/css">
        body {
            padding-bottom: 40px;
        }

        .sidebar-nav {
            padding: 9px 0;
        }
    </style>
    <script src="http://lib.sinaapp.com/js/jquery/2.2.4/jquery-2.2.4.min.js"></script>
    <script src="../js/common/public.js"></script>
    <script src="../js/base64.js"></script>
    <script src="../js/bootstrap-modal.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {

            var urlMsg = parseUrl(window.location.search);
            $("#token").val(urlMsg.token);
            if (urlMsg.token != null) {
                var token = decode(urlMsg.token);
            }
            $('#exportDataList').attr('href','exportDataList.html?token='+token);
            var year = $.ajax({
                type: "GET",
                url: "http://localhost:1068/admin/class/findAllClassNumber?token=" + token,
                async: false
            }).responseText;
            var yearReuslt = eval('(' + year + ')');
            if (yearReuslt.code != 200) {
                alert(yearReuslt.msg)
            } else {
                if (yearReuslt.data != null) {
                    for (index in yearReuslt.data) {
                        $("#year").append("<option value='" + yearReuslt.data[index] + "'>" + yearReuslt.data[index] + "</option>")
                    }
                }
            }
        });


        function getClassName() {
            var urlMsg = parseUrl(window.location.search);
            $("#token").val(urlMsg.token);
            if (urlMsg.token != null) {
                var token = decode(urlMsg.token);
                token = token.substring(0, token.length - 1);
            }
            var year = $("#year").val();
            var classHtml = $.ajax({
                type: "GET",
                url: "http://localhost:1068/admin/class/findClassByYear?token=" + token + "&year=" + year,
                async: false
            }).responseText;
            var classResult = eval('(' + classHtml + ')');
            if (classResult.code != 200) {
                alert(classResult.msg)
            } else {
                $("#className").empty();
                if (classResult.data != null) {
                    $("#className").append("<option value='0'>请选择班级</option>")
                    for (index in classResult.data) {
                        $("#className").append("<option value='" + classResult.data[index].classNumber + "'>" + classResult.data[index].className + "</option>")
                    }
                }
            }
        }

        function exportData() {
            $("#exportResult").text("文件导出中...！请等待导出结果，勿操作页面！");
            var urlMsg = parseUrl(window.location.search);
            var exportInfo = $("#exportInfo").val();
            var year = $("#year").val();
            var classNumber = $("#className").val();
            if (urlMsg.token != null) {
                var token = decode(urlMsg.token);
                token = token.substring(0, token.length - 1);
            }
           /* var year = $.ajax({
                type: "POST",
                url: "http://localhost:1068/admin/export",
                data: {token: token, exportInfo: exportInfo, year: year, classNumber: classNumber},
                async: false
            }).responseText;
            var yearReuslt = eval('(' + year + ')');
            if (yearReuslt.code != 200) {
                alert(yearReuslt.msg)
            } else {
                $("#exportResult").text("导出完毕！");
            }*/
            $.ajax({
                type: "POST",
                url: "http://localhost:1068/admin/export?token="+token+"&exportInfo="+exportInfo+"&year="+year+"&classNumber="+classNumber,
                processData: false,
                contentType: false,
                cache: false,
                timeout: 600000,
                success: function (data) {
                    $("#exportResult").text("导出完毕！");

                },
                error: function (e) {
                    $("#result").text(e.data);

                }
            });
        }
    </script>

</head>

<body>
<div class="container-fluid"
     style="padding-left:0px;padding-right:2px;">
    <div class="row-fluid">
        <div id="content" class="span10" style="width:100%;">
            <div class="row-fluid sortable">
                <div class="box span12">
                    <div class="box-header well">
                        <h2>
                            <i class="icon-edit"></i>导出数据信息
                        </h2>
                    </div>
                    <div class="box-content" style="text-align:center; padding-top:50px">
                        <form action="" method="post" enctype="multipart/form-data">
                            <input type="hidden" name="operatetype" value="export">
                            <fieldset>
                                <br>
                                <h1>导出数据信息</h1>
                                <br>
                                <br>
                                <br>
                                <div class="control-group">
                                    <div class="controls">
                                        <span style="font-size:14px">导出数据选择：</span>
                                        <select name="infotype" id="exportInfo" style="width:190px;">
                                            <option value="studentScoreInfo">学生操行信息</option>
                                            <option value="classScoreInfo">班级量化信息</option>
                                            <!-- <option value="studentinfo">学生信息</option> -->
                                        </select>
                                    </div>
                                </div>
                                <br>
                                <br>

                                <div class="control-group">
                                    <div class="controls">
                                        <span style="font-size:14px">请选择年级：</span>
                                        <select name="classscoreinfotype" id="year" style="width:190px;"
                                                onchange="getClassName()">
                                            <option value="0">选择导出年级</option>
                                        </select>
                                        <br>
                                    </div>
                                </div>
                                <br>
                                <br>

                                <div class="control-group">
                                    <div class="controls">
                                        <span style="font-size:14px">请选择班级：</span>
                                        <select name="studentscoreinfotype" id="className" style="width:190px;">
                                            <option value="0">选择导出班级</option>
                                        </select>
                                    </div>
                                </div>
                                <br>
                                <br>
                                <br>
                                <br>
                                <div class="control-group">
                                    <div class="controls">
                                        <span style="font-size:18px"><a href="" id="exportDataList">点此下载所有导出的数据</a></span>
                                    </div>
                                </div>
                                <br>
                                <br>
                                <div class="control-group">
                                    <div class="controls">
                                        <span style="font-size:10px; color:red" id="exportResult"></span>
                                    </div>
                                </div>
                                <br>
                                <div class="form-actions">
                                    <button type="button" onclick="exportData()" class="btn btn-primary" style="width:100px;">提交</button>
                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    <button class="btn" onclick="javascript:history.go(-1);" type="reset"
                                            style="width:100px;">取消
                                    </button>
                                </div>
                            </fieldset>
                        </form>

                        <div style="padding-left:190px; padding-right:190px; text-align:left">
                            <h1>注意事项</h1>
                            <br>
                            <br>
                            <p><b>1.</b>&nbsp;导出操行只选择年级则为导出所选年级所有班级操行信息。</p>
                            <br>
                            <p><b>2.</b>&nbsp;导出量化只选择年级。</p>
                            <br>
                            <p><b>3.</b>&nbsp;导出完成后请到导出页面点击文件名称进行下载。</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
</html>